layui.config({
    base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
}).extend({
    index: 'index' //主入口模块
}).use(['index','setter','commons'], function () {
    var setter = layui.setter;
    var commons = layui.commons;
    $(".commonScript").click(function(){
        layer.open({
            type: 2,
            area: ['100%', '100%'],
            title: ['脚本'],
            content:  serverPath.systemPath + setter.formLinkPath + "table/view/script?param=3"
        });
    });

    $(".cancelFrom").click(function () {
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    });

    $(".save").click(function () {
        InitMirror.save();

        var url = serverPath.workflowPath+"/workflow/bpmNodeScript/save";
        var type = $("#type").val();
        if(type == "ScriptTask"){
            url = serverPath.workflowPath+"/workflow/bpmNodeScript/saveScriptInModel";
        }
        var para = $('#bpmNodeScriptForm').serialize();
        $.ajax({
            url: url,
            type: "POST",
            dataType:"json",
            data: para,
            success: function (data) {
                if (commons._filterRecord(data)) {
                    window.parent.layer.alert(data.msg, function (index) {
                        parent.layer.close(index);
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    });
                } else {
                    window.parent.layer.alert(data.msg);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert("保存失败！" + XMLHttpRequest.status);
            },
        });
    });

});